﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@

@model OptionBindSample.Class
<h2>Index</h2>
<h3>ClassName:@Model.ClassName</h3>
<h3>ClassNo:@Model.ClassNo</h3>
<h4>Students</h4>

<div>
    @foreach (var item in Model.Students)
    {
        <span>Name: @item.Name</span>
        <span>Age: @item.Age</span>
    }
</div>


@using Microsoft.Extensions.Options;
@*@inject IOptions<OptionBindSample.Class> ClassAccpet;*@
@inject IOptionsSnapshot<OptionBindSample.Class> ClassAccpet;

<h2>直接读取数据</h2>
<h3>ClassName:@ClassAccpet.Value.ClassName</h3>
<h3>ClassNo:@ClassAccpet.Value.ClassNo</h3>
<h4>Students</h4>

<div>
    @foreach (var item in ClassAccpet.Value.Students)
    {
        <span>Name: @item.Name</span>
        <span>Age: @item.Age</span>
    }
</div>